<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item label="注册时间" prop="registerTime">
        <el-date-picker
          v-model="formInline.registerTime"
          type="datetimerange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
          :default-time="['00:00:00', '23:59:59']"
          :picker-options="pickerWeekStep">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="主账户余额">
        <el-col :span="11">
          <el-form-item prop="minBalance">
            <el-input v-model.trim="formInline.minBalance" placeholder="请输入" @keyup.enter.native="handleFilter"></el-input>
          </el-form-item>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-form-item prop="maxBalance">
            <el-input v-model.trim="formInline.maxBalance" placeholder="请输入" @keyup.enter.native="handleFilter"></el-input>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-form-item label="锁定状态" prop="status">
        <el-select v-model="formInline.status" placeholder="请选择状态">
          <el-option
            v-for="item in consts.ACCOUNT_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="在线状态" prop="online">
        <el-select v-model="formInline.online" placeholder="请选择状态">
          <el-option
            v-for="item in consts.ONLINE_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="玩家层级" prop="levelId">

        <el-select v-model="formInline.levelId" placeholder="请选择玩家层级">
          <el-option
            label="全部"
            :value="consts.ALL"
          ></el-option>
          <el-option
            v-for="item in levelList"
            :key="item.levelId"
            :label="item.name"
            :value="item.levelId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="with-pre-select" prop="keywords">
        <el-input placeholder="请输入关键词" v-model.trim="formInline.keywords" class="input-with-select" @keyup.enter.native="handleFilter">
          <!--搜索类型：1账户名，2姓名，3银行卡，4手机号，5邮箱，6IP，7上级代理，8备注-->
          <el-select v-model="formInline.searchType" slot="prepend" placeholder="请选择查询范围">
            <el-option label="账号名" :value="1"></el-option>
            <el-option label="姓名" :value="2"></el-option>
            <el-option label="银行卡" :value="3"></el-option>
            <el-option label="手机号" :value="4"></el-option>
            <el-option label="邮箱" :value="5"></el-option>
            <!-- <el-option label="IP（支持模糊搜索）" :value="6"></el-option> -->
            <el-option label="上级代理" :value="7"></el-option>
            <el-option label="备注" :value="8"></el-option>
          </el-select>
          <!--<el-button slot="append" icon="el-icon-search"></el-button>-->
        </el-input>
      </el-form-item>
      <el-form-item label="层级状态" prop="levelStatus">
        <el-select v-model="formInline.levelStatus" placeholder="请选择状态">
          <el-option
            v-for="item in consts.LEVEL_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>

       <el-form-item label="第三方平台" prop="channelId">
            <el-select v-model="formInline.channelId">
                <el-option
                    v-for="item in consts.PLATFORM_THIRD"
                    :label="item.channelName"
                    :key="item.channelId"
                    :value="item.channelId"
                ></el-option>
            </el-select>
        </el-form-item>

       <el-form-item label="第三方账户名" prop="thirdPartyUserName">
            <el-col >
                <el-input v-model.trim="formInline.thirdPartyUserName" placeholder="请输入" @keyup.enter.native="handleFilter"></el-input>
            </el-col>
        </el-form-item>
      <el-form-item label="VIP状态" prop="lockStatus">
            <el-select v-model="formInline.lockStatus">
                <el-option
                v-for="item in vipManage.MEMBER_VIP_STATUS"
                :label="item.label"
                 :key="item.value"
                :value="item.value">
                </el-option>
            </el-select>
        </el-form-item>
      <el-button class="filter-item" type="primary" :loading="loading" icon="el-icon-search" @click="handleFilter">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
import { getUserLevelList } from '@/services/api/userLevel';
import { form, pickerOption } from '@/build';
import ElRangeInput from '@/components/ElRangeInput/index';

export default {
  name: 'form-filter',
  components: { ElRangeInput },
  mixins: [form, pickerOption],
  data() {
    return {
      levelList: [],
      formInline: {
        userType: 0, // 0玩家，1代理
        registerTime: [
          moment(consts.ONLINE_DATE).format('YYYY-MM-DD 00:00:00'),
          moment().format('YYYY-MM-DD 23:59:59'),
        ],
        minBalance: undefined,
        maxBalance: undefined,
        status: undefined,
        levelId: -1,
        searchType: 1,
        keywords: undefined,
        online: -1,
        balanceRange: [null, null],
        levelStatus: -1,
        channelId: -1,
        thirdPartyUserName: '',
        lockStatus: '',
      },
    };
  },
  methods: {
    handleFilter() {
      this.$emit('submit-form', this.formInline);
    },
    selfResetForm(formname) {
      this.resetForm(formname);
      this.handleFilter();
    },
  },
  mounted() {
    this.bindGet(getUserLevelList, 'levelList', {
      sendingData: { levelType: 0 },
    });
    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 160px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
